package com.isias.system.service.Impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.isias.model.system.SysLoginLog;
import com.isias.model.vo.SysLoginLogQueryVo;
import com.isias.system.mapper.LoginLogMapper;
import com.isias.system.Service.LoginLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(rollbackFor = Exception.class)
public class LoginLogServiceImpl extends ServiceImpl<LoginLogMapper, SysLoginLog> implements LoginLogService {

    @Autowired
    private LoginLogMapper loginLogMapper;

    @Override
    public boolean AddLoginLog(String username, String ipaddr, Integer status, String msg) {
        SysLoginLog sysLoginLog = new SysLoginLog();
        sysLoginLog.setMsg(msg);
        sysLoginLog.setIpaddr(ipaddr);
        sysLoginLog.setStatus(status);
        sysLoginLog.setUsername(username);
        int insert = loginLogMapper.insert(sysLoginLog);

        return insert==1;
    }


    @Autowired
    private LoginLogMapper LoginLogMapper;

    @Override
    public IPage<SysLoginLog> selectPage(Page<SysLoginLog> pageParam, SysLoginLogQueryVo sysLoginLogQueryVo) {
        return LoginLogMapper.selectPage(pageParam, sysLoginLogQueryVo);
    }


//    @Override
//    public SysLoginLog getById(Long id) {
//        return null;
//    }
}
